package com.automannn.websoketmqtt.provider.config;

/**
 * @author chenkh
 * @time 2020/10/13 11:43
 */

import com.automannn.websoketmqtt.common.amqp.FanoutGlobalValue;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 扇形交换机配置
 */
@Configuration
public class FanoutRabbitConfig {

    /**
     * 队列配置
     */
    @Bean
    public Queue automannnQueueA(){
        return new Queue(FanoutGlobalValue.FANOUT_Q_A);
    }

    /**
     * 队列配置
     */
    @Bean
    public Queue automannnQueueB(){
        return new Queue(FanoutGlobalValue.FANOUT_Q_B);
    }

    /**
     * 队列配置
     */
    @Bean
    public Queue automannnQueueC(){
        return new Queue(FanoutGlobalValue.FANOUT_Q_C);
    }

    /**
     * 交换机配置
     */
    @Bean
    public FanoutExchange automannnFanoutExchange(){
        return new FanoutExchange(FanoutGlobalValue.FANOUT_EXCHANGE_NAME);
    }

    /**
     * 绑定
     */
    @Bean
    public Binding bindingExchangeA(){
        return BindingBuilder.bind(automannnQueueA()).to(automannnFanoutExchange());
    }

    /**
     * 绑定
     */
    @Bean
    public Binding bindingExchangeB(){
        return BindingBuilder.bind(automannnQueueB()).to(automannnFanoutExchange());
    }

    /**
     * 绑定
     */
    @Bean
    public Binding bindingExchangeC(){
        return BindingBuilder.bind(automannnQueueC()).to(automannnFanoutExchange());
    }
}
